﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ATM
{
    public static class StaticFunction
    {
        public static string NumberFormat(this object input)
        {
            string s = input.ToString();
            int i = 0;
            if (s.Length % 3 == 0)
            {
                for (i = 3; i < s.Length; i += 4)
                {
                    s = s.Insert(i, ",");
                }
            }
            else if (s.Length % 3 == 1)
            {
                for (i = 1; i < s.Length; i += 4)
                {
                    s = s.Insert(i, ",");
                }
            }
            else
            {
                for (i = 2; i < s.Length; i += 4)
                {
                    s = s.Insert(i, ",");
                }
            }
            return s;
        }
    }
}